package nl.boelen.game.net.packet;

public class Packet30Health extends Packet {
    private static final int packetNumber = 30;
    private String uniqueKey;
    private int maxhp;
    private int hp;
    private boolean isDeath;

    public Packet30Health(byte[] data) {
        super(packetNumber);
        String[] datas = (readData(data)).split(":");
        this.uniqueKey = datas[0];
        this.maxhp = Integer.parseInt(datas[1]);
        this.hp = Integer.parseInt(datas[2]);
        this.isDeath = Integer.parseInt(datas[3]) == 1;
    }

    public Packet30Health(String uniqueKey, float maxhp, float hp, boolean isDeath) {
        super(packetNumber);
        this.uniqueKey = uniqueKey;
        this.maxhp = (int) maxhp;
        this.hp = (int) hp;
        this.isDeath = isDeath;
    }

    @Override
    public byte[] getData() {
        return (packetNumber + this.uniqueKey + ":" + this.maxhp + ":" + this.hp + ":" + (isDeath ? 1 : 0)).getBytes();
    }

    public String getUniqueKey() {
        return uniqueKey;
    }

    public int getMaxhp() {
        return maxhp;
    }

    public int getHp() {
        return hp;
    }

    public boolean isDeath() {
        return isDeath;
    }
}